# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=yajl
pkgver=2.1.0
pkgrel=8
pkgdesc="Yet Another JSON Library (YAJL)"
url="https://lloyd.github.io/yajl/"
arch="all"
license="MIT"
makedepends="cmake samurai"
subpackages="$pkgname-static $pkgname-dev $pkgname-tools"
source="$pkgname-$pkgver-2.tar.gz::https://github.com/lloyd/yajl/archive/refs/tags/$pkgver.tar.gz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	mkdir -p "$pkgdir"/usr/lib
	mv "$pkgdir"/usr/share/pkgconfig "$pkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/libyajl_s.a "$pkgdir"/usr/lib/libyajl.a
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

tools() {
	pkgdesc="JSON tools based on Yajl"

	amove usr/bin
}

sha512sums="
9e786d080803df80ec03a9c2f447501e6e8e433a6baf636824bc1d50ecf4f5f80d7dfb1d47958aeb0a30fe459bd0ef033d41bc6a79e1dc6e6b5eade930b19b02  yajl-2.1.0-2.tar.gz
"
